struct  dl_t {
    dl_t *next;
    dl_t *prev;
    dl_t *head;
    dl_t *tail;

    dl_t(): next(0), prev(0), head(0), tail(0) {}
    void insert(dl_t *n, dl_t *nextp) {
        if (nextp) {
            n->next = nextp;
            n->prev = nextp->prev;
            if (n->prev) {
                n->prev->next = n;
            } else {
                this->head = n;
            }
            nextp->prev = n;
        } else {
            n->prev = this->tail;
            if (this->tail) {
                this->tail->next = n;
            }
            this->tail = n;
            if (this->head == NULL) {
                this->head = n;
            }
        }
    }
    void remove(dl_t *n) {
        if (n->next) {
            n->next->prev = n->prev;
        } else {
            tail = n->prev;
        }
        if (n->prev) {
            n->prev->next = n->next;
        } else {
            head = n->next;
        }
        n->prev = NULL;
        n->next = NULL;
    }
};

class func_cache_t:public dl_t {
    char cmd[256];
    char fn[1024];
    public:
    char *get_func(char *cmd) {
        for (func_cache_t *p = (func_cache_t *)head;p;p = (func_cache_t *)p->next) {
            if (strcmp(p->cmd, cmd) == 0) {
                return p->fn;
            }
        }
        return NULL;
    }

    void new_func(char *cmd, char *name) {
        func_cache_t *p = new func_cache_t;
        strcpy(p->cmd, cmd);
        strcpy(p->fn, name);
        insert(p, NULL);
    };
};
